import router from '../router'
let layer=window.layer;
let $=window.$;
let lIndex;
{
	$('body').on('click.e_back','.e_back',function(){
		router.go(-1);
	}).on('click.e_refresh','.e_refresh',function(){
		router.go(0);
	}).on('click.e_close','.e_close',function(){
		hideError();
	});
}

export const showError=(msg,type)=>{
	if(type==1) {
		layer.msg(msg);
	}else{
		lIndex=layer.open({
			type:1,
			area:['100%','100%'],
			title: false,
			closeBtn: 0,
			scrollbar: false,
			id:'errorPage',
			anim:false,
			content: `<div class="container container-table">
							<div class="row vertical-10p">
									<div class="container">
											<img src="/static/img/logo.png" class="center-block logo">
											<div class="text-center col-sm-6 col-sm-offset-3">
													<h1>简单讲就是出错啦！</h1>
													<h4>${msg}</h4>
													<div class="error_ops">
														<a class="e_back">返回</a>
														<a class="e_refresh">重新加载试试？</a>
														<a class="e_close">我不听，就要关!</a>
													</div>
											</div>
									</div>
							</div>
					</div>`
		});
	}
}
export const hideError=()=>{
	layer.close(lIndex);
}
